fix(lifecycle): gate Codex research on fresh evidence and preserve risk bans - #595
Merged
Conversation
…sk bans Co-Authored-By: Codex <noreply@openai.com>
Co-Authored-By: Codex <noreply@openai.com>
Co-Authored-By: Codex <noreply@openai.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Old or undated drift observations could be treated as current and start research. The probe now preserves observation time and matching source identity, uses an explicit replay clock and a seven-calendar-day default validity window, and rejects stale, future or unavailable evidence. Existing REVIEW/CRITICAL risk prohibitions remain effective even when research is unavailable. Missing dates remain null across storage and reporting.
The autopilot binds to the existing actionable research cycle with subscription-based diagnosis, bounded search, strict WFA/OOS evidence, paired shadow and confirmed console delivery. Research defaults to Codex; AI_GATEWAY_RESEARCH_PROVIDERS explicitly permits Cursor or Codex→Cursor admission routing through the gateway. Missing callbacks stop before AI/optimization, quota deferral is retained, and human acceptance does not grant live authority. Old gateways/SDKs cannot silently accept the new route; admitted task and route identity are checked, failures are sanitized, and a submitted job never retries through the reliability/API fallback.
Console delivery now reads the exact ticket before and after creation. A confirmed 404 permits one POST; unavailable reads do not authorize writes, and an uncertain write is reconciled without another POST from the same callback. Full candidate, budget, evidence and state must match, including Python/JavaScript numeric serialization. The normal research cycle and CLI share saved-ticket decision recovery; matching accept/reject decisions are saved atomically as intent only, while pending or just-recovered profiles skip new research in that cycle. Existing terminal tickets are idempotent no-ops; cross-run experiment dispatch/deduplication remains separate integration work.
Validation: 219 tests and 14 subtests passed across 16 related files, including 32 freshness cases. Full Ruff passed after removing one duplicate test import; the affected 11 probe tests also passed. Independent review checked date/source consumers and ran 12 additional offline assertions. Existing strict cycle and paired-shadow fixtures passed; they are not real forward-shadow evidence.
Decision-recovery follow-up: 171 related tests and 97 subtests passed, including 46 new regression cases. Independent localhost HTTP integration used the real QRT Worker with synthetic in-memory KV/session to verify submit/readback, duplicate suppression, anonymous/stale-candidate rejection, accept/reject recovery and no live authority. Each case made exactly one ticket POST. This validates application wiring, not deployed authentication, durable cloud KV or real research/shadow evidence.
Subscription consumer validation: four related files passed with 103 tests and 26 subtests. Independent review reproduced incorrect task binding and raw error propagation; both now have failing-before/fixed-after regressions and independent closure. Ruff and diff checks passed. These are offline checks, not Cursor model or billing validation.
Adoption: deploy/install the service and SDK from QuantStrategyLab/AIAuditBridge#165 before enabling the consumer route. Adopt the new probe and risk mapper together from one QPK package; copying only the probe can lose retained risk prohibitions. No deployment, dependency-pin rollout, model call or trading action is performed by this PR. A real experiment job and approved data/shadow bindings remain outstanding.